@echo off
chcp 65001 >nul
title Git Multi-Account Manager

echo ================================
echo Git Multi-Account Manager
echo ================================
echo.

echo [1/5] Checking Python...
python --version >nul 2>&1
if errorlevel 1 (
    echo ERROR: Python not found!
    echo Please install Python 3.8+ from https://www.python.org/downloads/
    pause
    exit /b 1
)
echo OK: Python detected
echo.

echo [2/5] Setting up virtual environment...
if not exist "venv" (
    echo Creating virtual environment...
    python -m venv venv
    if errorlevel 1 (
        echo ERROR: Failed to create virtual environment
        pause
        exit /b 1
    )
    echo OK: Virtual environment created
) else (
    echo OK: Virtual environment exists
)
echo.

echo [3/5] Activating virtual environment...
call venv\Scripts\activate.bat
if errorlevel 1 (
    echo ERROR: Failed to activate virtual environment
    pause
    exit /b 1
)
echo OK: Virtual environment activated
echo.

echo [4/5] Installing dependencies...
python -m pip install --upgrade pip --quiet
python -c "import streamlit, cryptography" >nul 2>&1
if errorlevel 1 (
    echo Installing required packages...
    pip install -r requirements.txt
    if errorlevel 1 (
        echo ERROR: Failed to install dependencies
        pause
        exit /b 1
    )
    echo OK: Dependencies installed
) else (
    echo OK: Dependencies already installed
)
echo.

echo [5/5] Starting application...
echo.
echo ================================
echo Application starting...
echo Browser will open at: http://localhost:8501
echo Press Ctrl+C to stop
echo ================================
echo.

streamlit run app.py

echo.
echo Application stopped.
pause